#!/usr/bin/env bash

# 发布脚本

# 构建号，取jenkins的构建号
build_num=$BUILD_NUMBER

# 发布的类型,取jenkins的发布类型
publishType=$jenkinsPublishType

# 要发布的模块名称
module=$moduleName

if [[ "$module" == "" ]]; then
    echo "必须指定构建模块！"
    exit 1
fi

# 入参检查，如果为空的话，就设置为默认值
if [[ "$build_num" == "" ]]; then
    build_num=1
fi

# 入参检查，如果为空的话，就设置为默认值
if [[ "$publishType" == "" ]]; then
    publishType="release"
fi

echo "模块：$module"
echo "发布类型：$publishType"
echo "构建号：$build_num"

# 执行构建和发布
if [[ "$publishType" == "release" ]]; then
    ./gradlew :$module:publish -PMAVEN_BUILD_CODE=$build_num -PIS_SNAPSHOT="false"
else
    ./gradlew :$module:publish -PMAVEN_BUILD_CODE=$build_num -PIS_SNAPSHOT="true"
fi

